'use strict';
stareal
    .controller("IndexController", function ($scope,$stateParams, $api, $alert, $document, localStorageService, $state,$timeout,$compile) {
        $scope.mypage=1;
        $scope.showRIlInfo=false;
        $scope.TopPage=0;
        $scope.dataTest=['1','2','3','4','5','6'];
        // $scope.mypage = 2;
        $scope.IndexCityName='全国';
        $scope.IndexCityId='-1';
        $scope.nowDateIndex=new Date().getTime();
       // console.log( $scope.nowDateIndex);
        $api.get("app/homeInformation/search",{},true) //本地最近五条信息
            .then(function (ret) {
               // console.log(ret);
                $scope.datasetDataNew = ret.data.slice(0,10);
                $timeout(function(){
                    var className = $(".slideUl");
                    var i = 0,sh;
                    var liLength = className.children("li").length;
                    var liHeight = 0.88*parseFloat(document.documentElement.style.fontSize);//className.children("li").height(); //+ parseInt(className.children("li").css('border-bottom-width'));
                    // console.log(liLength);
                    // console.log(liHeight);
                    var html = className.html() + className.html();
                    var $html = $compile(html)($scope);
                    className.append($html);
                    sh = setInterval(slide,3000);
                    function slide(){
                        if (parseInt(className.css("margin-top")) > (-liLength *  liHeight)) {
                            i++;
                            className.animate({
                                marginTop : -liHeight * i + "px"
                            },"slow");
                        } else {
                            i = 0;
                            className.css("margin-top","0px");
                        }
                    }
                },0)
            },function (err) {
                $alert.show(err)
            })
        if($stateParams.cordeId!=undefined&&$stateParams.cordeId!=null&&$stateParams.cordeId!=''){
            $scope.codeId=$stateParams.cordeId;
            localStorageService.set('H5CorderId',$stateParams.cordeId);
            var ua = navigator.userAgent.toLowerCase();
            $scope.IP=returnCitySN["cip"];  //app/channel/register
            $api.post("app/channel/h5PvAndIosMsg", {
                device_msg:ua,
                ip:$scope.IP,
                code: $scope.codeId,
                source:'mobile'
            },true).then(function (ret){
                console.log(ret);
            },function(err){
                $alert.show(err);
            });
        }
        $scope.user = localStorageService.get("user");
        $scope.dowload_appContentStatus=false;
        $scope.my_sing =1;//我的页面隐藏gif图
        var h=$(window).height()-3.0*parseFloat(document.documentElement.style.fontSize)+"px";
        $("#wrapper_container").height(h);
        var myDate = new Date();
        myDate.getYear();        //获取当前年份(2位)
        myDate.getFullYear();    //获取完整的年份(4位,1970-????)
        myDate.getMonth();       //获取当前月份(0-11,0代表1月)
        myDate.getDate();        //获取当前日(1-31)
        if(myDate.getDate()<10){
            $scope.today="0"+myDate.getDate();
        }else{
            $scope.today=myDate.getDate();
        }
        if(localStorageService.get('token')!=''&&localStorageService.get('token')!=null&&localStorageService.get('token')!=undefined){
            if(localStorageService.get("RepayPrice")!=undefined&&localStorageService.get("RepayPrice")!=null&&localStorageService.get("RepayPrice")!=""&&localStorageService.get("RepayPrice")!=0){
                if(localStorageService.get("RepayPriceOrder")!=undefined&&localStorageService.get("RepayPriceOrder")!=null&&localStorageService.get("RepayPriceOrder")!=''){
                    localStorageService.set("RepayPrice",0);
                    $state.go('my.rechargePaySuccess',{}.true);
                }
            }
        }

        //滚动出现下载app提示
        var nDivHight =10*parseFloat(document.documentElement.style.fontSize);
        var TopArrow=10*parseFloat(document.documentElement.style.fontSize);
        $("#wrapper_container").scroll(function(){
            var nScrollTop = $(this)[0].scrollTop;
            if(!$scope.dowload_appContentStatus){
                if(nScrollTop >= nDivHight){
                    $("#dowload_appContent").css('display','block');
                    $scope.TopPage=1;
                    $("#public_headline").css('top','1.4rem');
                }else{
                    $("#dowload_appContent").css('display','none');
                    $scope.TopPage=0;
                    $("#public_headline").css('top','0');
                }
            }
            $scope.topMove=function(){   //运动的函数
                    angular.element('#wrapper_container').animate({
                        scrollTop:0
                    },1000)
                   $scope.TopPage=0
                }

        });
        $scope.closedDowload=function(){
            $scope.dowload_appContentStatus=true;
            $("#dowload_appContent").css('display','none');
            $("#public_headline").css('top','0');
        }
        //获取城市  localStorageService.set('cityStatus',false);
        $scope.localeCityId=localStorageService.get('cityid');
        if( $scope.localeCityId==null||$scope.localeCityId==undefined){
            $api.get("app/city/list")
                .then(function (ret){
                    $scope.cities=ret.data;
                    var  map= new AMap.Map('position_center');
                    //实例化城市
                    var geolocation = null;
                    map.plugin('AMap.Geolocation', function () {
                        geolocation = new AMap.Geolocation({
                            enableHighAccuracy: true,//是否使用高精度定位，默认:true
                            timeout: 10000,          //超过10秒后停止定位，默认：无穷大
                            maximumAge: 0,           //定位结果缓存0毫秒，默认：0
                            convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                            showButton: true,        //显示定位按钮，默认：true
                            buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
                            buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                            showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
                            showCircle: true,        //定位成功后用圆圈表示定位精度范围，默认：true
                            panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
                            zoomToAccuracy:true      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                        });
                        map.addControl(geolocation);
                        geolocation.getCurrentPosition(function(status,result){
                            if(status=='complete'){
                                if(result.addressComponent.city!=''&&result.addressComponent.city!=null&&result.addressComponent.city!=undefined){
                                    var arr=result.addressComponent.city.split('市');
                                }else{
                                    var arr=result.addressComponent.province.split('市');
                                }
                                localStorageService.set('longitude',result.position.lng);
                                localStorageService.set('latitude',result.position.lat);
                                localStorageService.set('currentPOSITIONID',arr[0]);
                                for(var i=0;i< $scope.cities.length;i++) {
                                    if ($scope.cities[i].name == arr[0]) {
                                        $scope.currentPOSITIONID=$scope.cities[i].name;
                                        $scope.currentPOSITIONIDID=$scope.cities[i].id

                                    }
                                }
                                $("#current_ationSHOW").show();
                            }else{
                                $alert.show('定位失败！');
                                $("#current_city").html("全国");
                                localStorageService.set('cityname', "全国");
                                localStorageService.set('cityid','-1');//全国默认
                                $scope.IndexCityName='全国';
                                $scope.IndexCityId='-1';
                            }
                        });
                    });
                });
        }else{
            $("#current_city").html(localStorageService.get('cityname'));
            $scope.IndexCityName=localStorageService.get('cityname');
            $scope.IndexCityId=localStorageService.get('cityid');
        }
        var rs = localStorageService.get('rs');
        var token=localStorageService.get('token');
        var isbind = localStorageService.get('isbind');
        var openID = localStorageService.get('openid');
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            if (isbind!='1' && openID!= '') {
                if(localStorageService.get('redirectUrL')==''||localStorageService.get('redirectUrL')==null||localStorageService.get('redirectUrL')==undefined){
                    localStorageService.set('cleartoken', token);
                    localStorageService.set('token', '');
                    // $alert.show('2222');
                    location.href = "#/main/register/" + encodeURIComponent(rs);
                    return false;
                }else{
                    //   $alert.show(localStorageService.get('redirectUrL'));
                    localStorageService.set('cleartoken', token);
                    localStorageService.set('token', '');
                    location.href = "#/main/registerDui/1" ;
                    return false;
                }

            }else if(isbind=='1' && openID!= ''){
                //  $alert.show('333');
                // if($('#redirectUrL')!=null&&$('#redirectUrL')!=undefined){
                if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                    // $alert.show($('#redirectUrL').html());
                    if($('#redirectUrL').html()!=''&&$('#redirectUrL').html()!=null&&$('#redirectUrL').html()!=undefined) {
                        localStorageService.set('redirectUrL',$('#redirectUrL').html());
                    }
                }
                if(localStorageService.get('redirectUrL')!=''&&localStorageService.get('redirectUrL')!=null&&localStorageService.get('redirectUrL')!=undefined) {
                    // $alert.show(localStorageService.get('redirectUrL'));
                    var strUrl = decodeURIComponent(localStorageService.get('redirectUrL'));
                    var reg = new RegExp( 'amp;' , "g" )
                    var newStrUrl = strUrl.replace( reg , '' )+'&isApp=1';;
                    $api.get("app/duiba/shareH5", {dbredirect: newStrUrl}, true)
                        .then(function (ret) {
                            var data = ret.data;
                            console.log(data);
                            var link = data.url;
                            console.log(link);
                            window.location.href = link;
                            //window.open('https://activity.m.duiba.com.cn/chome/index?from=login&spm=53694.1.1.1','_blank');
                        },function(err){
                            $alert.show(err);
                        })
                    return false;
                }

            }
        }
        //切换定位城市
        $scope.swicthPosition=function(){
            $("#current_city").html( $scope.currentPOSITIONID);
            $scope.IndexCityName=$scope.currentPOSITIONID;
            $scope.IndexCityId= $scope.currentPOSITIONIDID;
            localStorageService.set('cityid', $scope.currentPOSITIONIDID);
            localStorageService.set('cityname',$scope.currentPOSITIONID);
            $("#current_ationSHOW").hide();
            location.reload();
        }
        //面向对象
        $scope.IndexFuc={
            //新版首页  广告banner   classify1是轮播图 classify2是banner推荐位 classify3是主推观演记 classify4是主推演出
            getIndexBanners:function(){
                $api.get("app/sowing/list",{cityName:$scope.IndexCityName}, true)
                    .then(function (ret) {
                      var data=ret.data;
                      $scope.advs=data.classify1;
                      $scope.IndexbannerAdvs=data.classify2;
                      $scope.IndexViewBanner=data.classify3;
                      $scope.IndexPepoBanner=data.classify4;
                        $scope.IndexFuc.getIndexRepertoire();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //新版 热门演出  请求所需字段：cityId	城市ID   typeId	类型id（1-热门演出;2-展览推荐;3-其他演出）
           getIndexRepertoire:function(){
               $api.get("app/hotGoods/queryHotGoods",{cityName:$scope.IndexCityName,typeId:1}, true)
                   .then(function (ret) {
                     var data=ret.data;
                   $scope.IndexHotRepertoires=data;
                       $scope.IndexFuc.getIndexRepertoireVenus();
                   },function(err){
                       $alert.show(err)
                   })
            },
            //新版 展览推荐  请求所需字段：cityId	城市ID   typeId	类型id（1-热门演出;2-展览推荐;3-其他演出）
            getIndexRepertoireVenus:function(){
                $api.get("app/hotGoods/queryHotGoods",{cityName:$scope.IndexCityName,typeId:2}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexRepertoireVenus=data;
                        $scope.IndexFuc.getIndexRepertoireOhters();
                    },function(err){
                        $alert.show(err)
                    })
            }, //新版 其他演出  请求所需字段：cityId	城市ID   typeId	类型id（1-热门演出;2-展览推荐;3-其他演出）
            getIndexRepertoireOhters:function(){
                $api.get("app/hotGoods/queryHotGoods",{cityName:$scope.IndexCityName,typeId:3}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexRepertoireOhters=data;
                        $scope.IndexFuc.getIndexActiveHots();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //抽奖活动
            getIndexActiveHots:function(){
                $api.get("app/homeActivityRecommend/search",{cityName:$scope.IndexCityName}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexActiveHots=data;
                        $scope.IndexFuc.getIndexRepoHots();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //精选REPO  app/homeArticle/search
            getIndexRepoHots:function(){
                $api.get("app/homeArticle/search",{cityName:$scope.IndexCityName}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexRepoHots=data;
                        $scope.IndexFuc.getIndexRecommendHots();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //达人推荐
            getIndexRecommendHots:function(){
                $api.get("app/homeUserRecommend/search",{}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexRecommendHots=data;
                        $scope.IndexFuc.getIndexHotVideos();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //热门视频  app/videos/homeHotVideos
            getIndexHotVideos:function(){
                $api.get("app/videos/homeHotVideos",{cityName:$scope.IndexCityName}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexHotVideos=data;
                        $scope.IndexFuc.getIndexHotcelebritysList();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //展览攻略 app/homeArticle/celebritysList    citySituationName
            getIndexHotcelebritysList:function(){
                $api.get("app/homeArticle/celebritysList",{cityName:$scope.IndexCityName}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexHotcelebritysLists=data;
                        $scope.IndexFuc.getIndexspecialRecommends();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //专题推荐    app/special/specialRecommend   citySituationId   专题类型id,11观演记，12攻略专题，13演出专题，14活动专题
            getIndexspecialRecommends:function(){
                $api.get("app/special/specialRecommend",{cityName:$scope.IndexCityName,citySituationId:$scope.IndexCityId}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexspecialRecommends=data;
                        $scope.IndexFuc.getIndexhomeSiteStrategy();
                    },function(err){
                        $alert.show(err)
                    })
            },
            //场馆攻略  app/site/homeSiteStrategy
            getIndexhomeSiteStrategy:function(){
                $api.get("app/site/homeSiteStrategy",{cityName:$scope.IndexCityName,citySituationId:$scope.IndexCityId}, true)
                    .then(function (ret) {
                        var data=ret.data;
                        $scope.IndexSiteStrategys=data;
                       // console.log(data);
                        if(localStorageService.get('token')!=''&&localStorageService.get('token')!=null&&localStorageService.get('token')!=undefined) {
                            $scope.qiandao();
                            $scope.GetCheck();
                        }
                    },function(err){
                        $alert.show(err);
                    })
            }
        }
        $scope.IndexFuc.getIndexBanners();
        $scope.GoToDetail=function(id,classFiD,idex,remark,db_url,activity_title,img){  ////1活动 2美图 3攻略 4资讯 5观演记 6 视频   1活动2美图3攻略4资讯5观演记6视频7演出8众筹 10用户11观演记专题12攻略专题13演出专题14活动专题  plate_id
            console.log(_czc);
            if(_czc!=undefined&&_czc!=null&&_czc!='') {
                _czc.push(["_trackEvent", 'h5-首页banner', idex, '点击', '', id]);
            }
            if(classFiD==1){
                $state.go('main.activedetail',{id:id},true);
            }else if(classFiD==2){
                $state.go('main.beautifulImgDetail',{id:id},true);
            }else if(classFiD==3){
                $state.go('main.raidersdetail',{id:id},true);
            }else if(classFiD==4){
                $state.go('main.newdetail',{newId:id},true);
            }else if(classFiD==5){ //main.newdetail
                $state.go('main.viewdetail',{id:id},true);
            }else if(classFiD==6){
                $state.go('main.videodetail',{id:id},true);
            }else if(classFiD==7){
                $state.go('main.detail',{good_id:id},true);
            }else if(classFiD==9){//外连接
               window.open(remark)
            }else if(classFiD==8){
                $state.go('main.raiseactivedetail',{id:id},true);
            }else if(classFiD==11){
                $state.go('main.viewsTopics',{id:id},true);
            }else if(classFiD==12){
                $state.go('main.raidersTopics',{id:id},true);
            }else if(classFiD==13){
                $state.go('main.PerformanceTopics',{id:id},true);
            }else if(classFiD==14){
                $state.go('main.ActiveTopics',{id:id},true);
            }else if(classFiD==15){//自定义兑吧
                $scope.goToOtherDui(db_url);
            }else if(classFiD==16){//通用兑吧  main.activeDui({id:good.remark,thumb:good.thumb,title:good.title})
                $state.go('main.activeDui',{id:db_url,thumb:img,title:activity_title},true);
            }
        }
        //兑吧自定义活动
        $scope.goToOtherDui=function(url){
            if(!localStorageService.get('token')){
                $scope.activeDuiDailogStatus=true;
                return false;
            }
            if(url!=''&&url!=undefined&&url!=null){
                $scope.venus360Id=url+'&isApp=1';
                $api.get("app/duiba/shareH5",{dbredirect:$scope.venus360Id},true)
                    .then(function (ret) {
                        var data=ret.data;
                        console.log(data);
                        var link=data.url;
                        console.log(link);
                        window.location.href=link;
                        // window.open(link);
                        //window.open('https://activity.m.duiba.com.cn/chome/index?from=login&spm=53694.1.1.1','_blank');
                    })
            }
        }
        $scope.closedActiveDailog=function(){
            $scope.activeDuiDailogStatus=false;
        }
        $scope.goTo=function(){
            var  rs = "main.index-" + JSON.stringify({});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                if (isbind != 1 && openID != '') {
                    localStorageService.set('cleartoken', token);
                    location.href = "#/main/register/" + encodeURIComponent(rs);
                    localStorageService.set('token', '');
                    return false
                }
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.index-" + JSON.stringify({});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    $api.get("app/oauth/index ", null, true)
                        .then(function (ret) {
                            console.log(ret)
                        });
                    // location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                    //     "appid=wxda73ac8ac7af1261&" +
                    //     "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                    //     "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    console.log(encodeURIComponent(rs));
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
        }
        //他人中心
        $scope.goViewPersonal=function(idex){
            $state.go('main.viewpersonal',{user_id:idex,kind:1},true);
        }
        ///member/checkin/thismonth
        $scope.GetCheck = function () {
            $api.get("app/member/checkin/thismonth",{},true)
                .then(function (ret) {
                    $scope.Sameday = ret.data
                    $scope.days = $scope.Sameday.length //当月共签到天数
                    $scope.Isday = [];  //需不需给默认值
                    for(var i =0;i<$scope.days;i++){
                        $scope.Isday.push($scope.Sameday[i].date.substring(6,8))
                    }
                    //日历函数
                    var d_Date = new Date();
                    var d_y = d_Date.getFullYear();
                    var d_m = d_Date.getMonth()+1;
                    var d_d = d_Date.getDate();
                    if(Number($scope.Isday[0])<Number(d_d)||$scope.Isday[0]==undefined){//和当天比较
                        $scope.showRIlInfo = true;   //没签到
                        localStorageService.set("sign-state","1")
                        $scope.qianSign();
                    }else{
                        $scope.showRIlInfo = false;  //已签到
                        localStorageService.set("sign-state","2")
                    }


                })
        }
        //签到 app/view/history
        $scope.showRili=function(){
            if (!localStorageService.get('token')) {
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state=&connect_redirect=1#wechat_redirect" ;
                    return false;
                } else {
                    location.href = "#/main/login/";
                    return false;
                }
            }else{
                $scope.showRIlInfo = true;
            }
            if(_czc!=undefined&&_czc!=null&&_czc!='') {
                _czc.push(["_trackEvent", 'h5-首页签到', '签到', '签到', 'sign', 'sign']);
            }
        }
        $scope.closeRili=function(){
            $scope.showRIlInfo = false;
        }
        $scope.indexweeks=['SUN','MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT' ];
        $scope.indexMonth=['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
        $scope.qiandao=function(){   //app/view/history  旧接口
            $api.get("app/view/historylist",{page_num: 1,page_size: 1},true)
                .then(function (ret) {
                    // console.log(ret);
                    var data=ret.data;
                    $scope.dayRiLDATA=data[0];
                    //   console.log($scope.dayRiLDATA);
                    var d_Date = new Date();
                    $scope.riliMonth=$scope.indexMonth[d_Date.getMonth()];
                    $scope.riliWeek=$scope.indexweeks[d_Date.getDay()];

                });
        }
        $scope.qianSign=function(){
            $api.get("app/member/checkin/create",{},true)
                .then(function (ret) {
                    // $scope.GetCheck();

                },function (err) {
                    $alert.show(err)
                })
        }

        //取消
        $scope.cancelPosition=function(){
            localStorageService.set('cityname', "全国");
            localStorageService.set('cityid','-1');//全国默认
            $("#current_ationSHOW").hide();
        }
        //列表
        $scope.completelatestRepeat=function(){
            var swiper = new Swiper('#Repertoire_containerIndex', {
                slidesPerView: 3,
                // slidesPerView: 3,
                slidesPerColumn: 2,
                slidesPerColumnFill : 'column',
                slidesPerGroup: 3,
                uniqueNavElements:true,
                spaceBetween:0,
                pagination: '#IndexRepertoire-pagination',//分页容器
                paginationType : 'custom',
                paginationCustomRender: function (swiper, current, total) {
                    var w=1/total *2.4+'rem';
                    var text = "<ul class='swiper-pagination-Indexthematic clear'>";
                    for (var i = 1; i <= total; i++){
                        if(current == i){
                            text += "<li class='swiper-pagination-Indexthematicbar active' style='width:"+w+"'></li>";
                        }else{
                            text += "<li class='swiper-pagination-Indexthematicbar' style='width:"+w+"'></li>";
                        }

                    }
                    text += "</ul>";
                    return text;
                },
                observer:true,
                observeParents:true,
            })
            $timeout(function () {
                /**增加class */
                swiper.setWrapperTransition(0);
                /**设置位移0 显示第一页 */
                swiper.setWrapperTranslate(0);
            },500)
        }
        //达人专题
        $scope.completelatestTopic=function(){
            var swiper = new Swiper('.IndexTattoo_topic_container', {
                slidesPerView: 'auto',
                freeMode: true,
                spaceBetween:0,
                pagination: '.IndexTattoo_topic_pagination',//分页容器
                paginationType : 'custom',
                observer:true,
                observeParents:true,
                paginationCustomRender: function (swiper, current, total) {
                    var w=1/total *2.4+'rem';
                    var text = "<ul class='swiper-pagination-Indexthematic clear'>";
                    for (var i = 1; i <= total; i++){
                        if(current == i){
                            text += "<li class='swiper-pagination-Indexthematicbar active' style='width:"+w+"'></li>";
                        }else{
                            text += "<li class='swiper-pagination-Indexthematicbar' style='width:"+w+"'></li>";
                        }

                    }
                    text += "</ul>";
                    return text;
                },
            })
            $timeout(function () {
                /**增加class */
                swiper.setWrapperTransition(0);
                /**设置位移0 显示第一页 */
                swiper.setWrapperTranslate(0);
            },500)
        }
        //滤镜
        $scope.completeIndexPepoBanner0Repeat=function(){
            setTimeout(function () {
                $(function () {
                    var $avatarEl = $('#special_IndexPepoavatar-holder0 .avatar');
                    var $avatarHolderEl = $('#special_IndexPepoavatar-holder0 .avatar-holder');
                    var avatars = [];
                    $avatarEl.each(function () {
                        var $avatar = $(this);
                        var avatarImage = $avatar.find('img').first().attr('src');
                        avatars.push(avatarImage);
                    });
                    $avatarHolderEl.each(function (i) {
                        var $avatarHold = $(this);
                        $avatarHold.backgroundBlur({
                            imageURL: avatars[i],
                            blurAmount: 30,
                        });
                    })
                });
            },300)
        }
        $scope.completeIndexPepoBannerRepeat=function(){
            setTimeout(function () {
                $(function () {
                    var $avatarEl = $('#special_IndexPepoavatar-holder .avatar');
                    var $avatarHolderEl = $('#special_IndexPepoavatar-holder .avatar-holder');
                    var avatars = [];
                    $avatarEl.each(function () {
                        var $avatar = $(this);
                        var avatarImage = $avatar.find('img').first().attr('src');
                        avatars.push(avatarImage);
                    });
                    $avatarHolderEl.each(function (i) {
                        var $avatarHold = $(this);
                        $avatarHold.backgroundBlur({
                            imageURL: avatars[i],
                            blurAmount: 30,
                        });
                    })
                });
            },300)
        }
        //专题推荐
        $scope.completelatestThematic=function(){
            setTimeout(function () {
                var swiperBg = new Swiper("#Indexthematic_recommendation_bgSwiper", {
                    effect: "fade",
                    observer:true,
                    observeParents:true,
                    fadeEffect: {
                        crossFade: !1
                    }
                });
                var  certifySwiper = new Swiper('.Indexthematic_recommendation_container', {
                    watchSlidesProgress: true,
                    slidesPerView: 'auto',
                    centeredSlides: true,
                    clickable :true,
                    pagination: '.Indexthematic_recommendation_pagination',//分页容器
                    paginationType : 'custom',
                    observer:true,
                    observeParents:true,
                    paginationCustomRender: function (swiper, current, total) {
                        var w=1/total *2.4+'rem';
                        var text = "<ul class='swiper-pagination-Indexthematic clear'>";
                        for (var i = 1; i <= total; i++){
                            if(current == i){
                                text += "<li class='swiper-pagination-Indexthematicbar active' style='width:"+w+"'></li>";
                            }else{
                                text += "<li class='swiper-pagination-Indexthematicbar' style='width:"+w+"'></li>";
                            }

                        }
                        text += "</ul>";
                        return text;
                    },
                    onProgress: function(swiper, progress){
                        //console.log(progress);
                        for (var i = 0; i < swiper.slides.length; i++) {
                            var slide = swiper.slides.eq(i);
                            var slideProgress = swiper.slides[i].progress;
                            var  modify = 1;
                            if (Math.abs(slideProgress) > 1) {
                                modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
                            }
                            var  translate = slideProgress * modify * parseFloat(document.documentElement.style.fontSize)*0.8 + 'px';
                            var   scale = 1 - Math.abs(slideProgress) /3;
                            var  zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
                            slide.transform('translateX(' + translate + ') scale(' + scale + ')');
                            slide.css('zIndex', zIndex);
                            slide.css('opacity', 1);
                        }

                    },
                    onClick: function(swiper){
                        //alert('你点了Swiper');
                    },
                    onSlideChangeEnd: function(swiper){
                        // alert(swiper.activeIndex) //切换结束时，告诉我现在是第几个slide
                        var slide = swiper.slides.eq(swiper.activeIndex);
                        var slideImg=$(slide).attr('data-img');
                        // $alert.show( slideImg);
                        // $("#Indexthematic_recommendation_bg").attr('src',slideImg);
                        // $("#Indexthematic_recommendation_bg").attr('ng-src',slideImg);
                    },
                    onSetTransition: function(swiper,transiton){
                        //自定义事件
                        for (var i = 0; i <  swiper.slides.length; i++) {
                            var slide =  swiper.slides.eq(i)
                            slide.transition(transiton);
                        }
                    },
                });
                certifySwiper.params.control = swiperBg;
                $(function(){
                    var $avatarEl = $('#Indexthematic_recommendation_bgSwiper .avatar');
                    var $avatarHolderEl = $('#Indexthematic_recommendation_bgSwiper .avatar-holder');
                    var avatars = [];
                    $avatarEl.each(function(){
                        var $avatar = $(this);
                        var avatarImage = $avatar.find('img').first().attr('src');
                        avatars.push(avatarImage);
                    });
                    $avatarHolderEl.each(function(i){
                        var $avatarHold = $(this);
                        $avatarHold .backgroundBlur({
                            imageURL: avatars[i],
                            blurAmount: 30,
                        });
                    })
                });
            },300)
        }
        //展览攻略
        $scope.completelatestThematicBanners=function(){
            setTimeout(function () {
                var swiperBg = new Swiper("#Indexthematic_banners_bg", {
                    effect: "fade",
                    observer:true,
                    observeParents:true,
                    fadeEffect: {
                        crossFade: !1
                    }
                });
                var  certifySwiper = new Swiper('.Indexthematic_banners_container', {
                    watchSlidesProgress: true,
                    slidesPerView: 'auto',
                    centeredSlides: true,
                    clickable :true,
                    pagination: '.Indexthematic_banners_pagination',//分页容器
                    paginationType : 'custom',
                    observer:true,
                    observeParents:true,
                    paginationCustomRender: function (swiper, current, total) {
                        var w=1/total *2.4+'rem';
                        var text = "<ul class='swiper-pagination-Indexthematic clear'>";
                        for (var i = 1; i <= total; i++){
                            if(current == i){
                                text += "<li class='swiper-pagination-Indexthematicbar active' style='width:"+w+"'></li>";
                            }else{
                                text += "<li class='swiper-pagination-Indexthematicbar' style='width:"+w+"'></li>";
                            }

                        }
                        text += "</ul>";
                        return text;
                    },
                    onProgress: function(swiper, progress){
                        //console.log(progress);
                        for (var i = 0; i < swiper.slides.length; i++) {
                            var slide = swiper.slides.eq(i);
                            var slideProgress = swiper.slides[i].progress;
                            var  modify = 1;
                            if (Math.abs(slideProgress) > 1) {
                                modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
                            }
                            var  translate = slideProgress * modify * parseFloat(document.documentElement.style.fontSize)*0.8 + 'px';
                            var   scale = 1 - Math.abs(slideProgress) /3;
                            var  zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
                            slide.transform('translateX(' + translate + ') scale(' + scale + ')');
                            slide.css('zIndex', zIndex);
                            slide.css('opacity', 1);
                        }

                    },
                    onClick: function(swiper){
                        //alert('你点了Swiper');
                    },
                    onSlideChangeEnd: function(swiper){
                        // alert(swiper.activeIndex) //切换结束时，告诉我现在是第几个slide
                        var slide = swiper.slides.eq(swiper.activeIndex);
                    },
                    onSetTransition: function(swiper,transiton){
                        //自定义事件
                        for (var i = 0; i <  swiper.slides.length; i++) {
                            var slide =  swiper.slides.eq(i)
                            slide.transition(transiton);
                        }
                    },
                })
                certifySwiper.params.control = swiperBg;
                $(function(){
                    var $avatarEl = $('#Indexthematic_banners_bg .avatar');
                    var $avatarHolderEl = $('#Indexthematic_banners_bg .avatar-holder');
                    var avatars = [];
                    $avatarEl.each(function(){
                        var $avatar = $(this);
                        var avatarImage = $avatar.find('img').first().attr('src');
                        avatars.push(avatarImage);
                    });
                    $avatarHolderEl.each(function(i){
                        var $avatarHold = $(this);
                        $avatarHold .backgroundBlur({
                            imageURL: avatars[i],
                            blurAmount: 30,
                        });
                    })
                });
            },300)
        }
        //埋点
        $scope.maiDian=function(type,action,label,id){
            if(_czc!=undefined&&_czc!=null&&_czc!='') {
                _czc.push(["_trackEvent", type, action, label, '', id]);
            }
        }
        // 列表2
        // var tabSubSwiper = new Swiper('.Peoplecolumn', {
        //     freeMode: true,
        //     slidesPerView: '2',
        //     freeModeSticky: true,
        //     observer:true,
        //     observeParents:true,
        // })
        if (!localStorageService.get('token')){ ///oauth/index
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger'){
                if($('#redirectUrL').html()!=''&&$('#redirectUrL').html()!=null&&$('#redirectUrL').html()!=undefined) {
                    localStorageService.set('redirectUrL',$('#redirectUrL').html());
                }
                // 正式地址
                $api.get("app/oauth/index ", null, true)
                    .then(function (ret) {
                        console.log(ret)
                    });
                // location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                //     "appid=wxda73ac8ac7af1261&" +
                // http%3A%2F%2Ftest.djx.api02.opentickets.cn%2Fmobile%2Fapp%2Foauth%2Findex
                //     "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                //     "&response_type=code&scope=snsapi_userinfo&state=&connect_redirect=1#wechat_redirect";
            }
            return false;
        }else{

            if($scope.user==undefined||$scope.user==null||$scope.user==''){
                $api.get("app/login/userinfo/retrieve", null, true)
                    .then(function (ret) {
                        $scope.user = ret.data;
                        localStorageService.set('user',ret.data);
                    });
            }
        }
        if(rs!=null&&rs!=undefined&&rs!=""){
            localStorageService.remove('rs');
            var _state = rs.substring(0, rs.indexOf('-'));
            var _param = rs.substring(rs.indexOf('-') + 1, rs.length);
            console.log(_state);
            console.log(_param);
            if(_state!=''&&_state!=undefined&&_state!=null){
                if (_param!=''&&_param!=undefined&&_param!=null) {
                    $state.go(_state, eval('(' + _param + ')'));
                }else{
                    localStorageService.remove('rs');
                    $state.go(_state,{},true);
                }
            }else{
                $state.go('main.index',{},true);
            }

        }
    });